'use strict';

const BaseController = require('../base');

class OrderLogController extends BaseController {
  static get serviceName() {
    return 'business.orderLog';
  }

  // 获取订单的日志列表
  async orderLogs() {
    const { ctx } = this;
    const { orderId } = ctx.params;
    const result = await this.service.getLogsByOrder(orderId);
    ctx.success(result);
  }

  // 创建订单日志
  async createLog() {
    const { ctx } = this;
    const data = ctx.request.body;
    const result = await this.service.createLog(data);
    ctx.success(result);
  }

  // 获取订单日志详情（包含操作人信息）
  async detail() {
    const { ctx } = this;
    const { id } = ctx.params;
    const result = await this.service.getDetailWithOperator(id);
    ctx.success(result);
  }

  // 获取订单操作历史
  async operationHistory() {
    const { ctx } = this;
    const { orderId } = ctx.params;
    const result = await this.service.getOperationHistory(orderId);
    ctx.success(result);
  }
}

module.exports = OrderLogController; 